# coding: utf8
import json
from utils.ypclient.yunpian import ClientV2

from django.conf import settings


# res = c.get_sms_tpl()  获取模版列表从而获取模版ID
class YunpianSms():
    def __init__(self):
        # api key
        self.client = ClientV2(settings.YUNPIAN_API_KEY)

    def send_register_sms(self, mobile, context):
        # 登录验证码短信
        tpl_id = settings.VERIFT_CODE_TPL_ID
        res = self.client.send_tpl_sms(
            mobile=mobile,
            tpl_id=tpl_id,
            tpl_context=context
        )
        print(json.dumps(res.json()))
        return res.json()


if __name__ == '__main__':
    # context = {
    #     "code": "694759",
    # }
    # sms = YunpianSms()
    # sms.send_register_sms("13212789782", context)
    pass

